package Project;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.ImageObserver;

/**
 * My own Graphics data structure for drawing basic
 * graphics such as rectangles, circles, lines, charaters
 * and so on.
 * 
 * @author	Brian Wetherbee
 * 			Ryan McNamara
 * 			Zeng Yang
 *
 */
public class MyGraphics {
	Graphics g;
	
	public MyGraphics(Graphics g) throws Exception {
		this.g = g;
		//throw new Exception("there is a better way!");
	}

	public void setColor(Color c) {
		g.setColor(c);
		
	}

	public void drawOval(double x, double y, double width, double height) {
		x = Main.internalToActualX(x);
		y = Main.internalToActualY(y);
		width = Main.internalToActualX(width);
		height = Main.internalToActualY(height);
		g.drawOval((int)x,(int)y,(int)width,(int)height);		
	}
	
	public void fillOval(double x, double y, double width, double height) {
		x = Main.internalToActualX(x);
		y = Main.internalToActualY(y);
		width = Main.internalToActualX(width);
		height = Main.internalToActualY(height);
		g.fillOval((int)x,(int)y,(int)width,(int)height);		
	}

	public void drawRect(double x, double y, double width, double height) {
		x = Main.internalToActualX(x);
		y = Main.internalToActualY(y);
		width = Main.internalToActualX(width);
		height = Main.internalToActualY(height);
		g.drawRect((int)x,(int)y,(int)width,(int)height);	
	}

	public void setFont(Font font) {
		font = new Font(font.getName(), font.getStyle(), (int)Math.min(Main.internalToActualX(font.getSize()),Main.internalToActualY(font.getSize())));
		g.setFont(font);
		
	}

	public FontMetrics getFontMetrics(Font font) {
		font = new Font(font.getName(), font.getStyle(), (int)Math.min(Main.internalToActualX(font.getSize()),Main.internalToActualY(font.getSize())));
		return g.getFontMetrics(font);
	}

	public void drawString(String string, double x, double y) {
		x = Main.internalToActualX(x);
		y = Main.internalToActualY(y);
		g.drawString(string, (int)x, (int)y);
		
	}

	public void fillRect(double x, double y, double width, double height) {
		g.fillRect((int)Main.internalToActualX(x),(int) Main.internalToActualY(y), (int)Main.internalToActualX(width), (int)Main.internalToActualY(height));
		
	}

	public void drawLine(double x, double y, double x2, double y2) {
		g.drawLine((int)Main.internalToActualX(x),(int) Main.internalToActualY(y), (int)Main.internalToActualX(x2), (int)Main.internalToActualY(y2));
		
		
	}

	public FontMetrics getFontMetrics() {
		return g.getFontMetrics();
	}

	public void drawImage(Image img, double x, double y, ImageObserver object) {

		g.drawImage(img, (int)Main.internalToActualX(x), (int)Main.internalToActualY(y), object);
		
	}
	
	
	
}
